function [ A ] = constructData2( num )
% construct multi-ellipsoid data
% generate random points on the surface, their velocity toward center
%--------------------------Generate----------------------------%
A = zeros(6*num,6);
radius = 5;
ratio = 1.2; % prolate axis divide minor axis; sphere: ratio = 1
Radius = 2*radius+0.1; % the number 0.1 is used to seperating ellipsoids 
vel = 1;
velAdd = 10;
velNoise = 0;
for j = 1 : 6
for i = (j-1)*num+1 : j*num
    randRaw = rand(1,2);
    h = 2 * radius * randRaw(1) - radius;
    d = (radius^2 - h^2)^0.5;
    theta = 2 * pi * randRaw(2);
    Theta = pi/6 + (j-1)*pi/3;
    A(i,1) = d * cos(theta) + Radius * cos(Theta); % position on x label
    A(i,2) = d * ratio * sin(theta) + Radius * sin(Theta);
    A(i,3) = h;
    A(i,4) = -d * cos(theta) * vel / radius + velAdd + velNoise * rand(1); % velocity on x label
    A(i,5) = -d * ratio * sin(theta) * vel / radius + velNoise * rand(1);
    A(i,6) = -h * vel / radius + velNoise * rand(1);
end
end
A = A'; % turn 6 columns to 6 rows for writing 
%----------------------------Plot------------------------------%
% figure(6)
% plot3(A(1,:),A(2,:),A(3,:),'r.');
% axis equal
% figure(7)
% plot3(A(4,:),A(5,:),A(6,:),'b.');

% quiver3(A(1,:),A(2,:),A(3,:),A(4,:),A(5,:),A(6,:));
% axis equal

%----------------------------Write------------------------------%

fid = fopen('G\generate2.txt','wt');
fprintf(fid,'%10.6f%10.6f%10.6f%10.6f%10.6f%10.6f\n',A); % Write A
fclose(fid);
end
